#ifndef FRACTALRECT_H
#define FRACTALRECT_H

#include <QtGui>
#include <QPair>
#include <QSize>

#include <QPointer>


//
class FractalRect : public QObject
{
     Q_OBJECT
//
public:
       static FractalRect* self( const int _wi , const int _hi , QObject *_parent );
       inline QSize  size()const;
       inline unsigned int width()const;
       inline unsigned int height()const;
       inline int steeps()const;
       inline QRect boundingRect()const;
       inline int summ()const { return chess.size(); }
       void paintImage(  QPainter *p   , const QRect viewpart  );
       QRect spin(const int iteration);
       inline QObject *parent() { return par; }
protected:
       QObject *par;
QSize _size;
  QMap<int,QRect> chess;
  int piece_splitmax;
 bool endingloop;
int _piece;
private:
    FractalRect( const int _wi , const int _hi , QObject *_parent  );
    void scanninsertLine(  const int y , bool ending  );
    void paintBorder(  QPainter *painter   ,  const QRect brect , const int pos );

    QLineF Diagonal_1( const QRect rect );
    QLineF Diagonal_0( const QRect rect );

    static QPointer<FractalRect> _self;

signals:
    void rdraw(QRect,int);
public slots:

};


// Inlined implementations
int FractalRect::steeps()const
{
    return piece_splitmax;
}

QRect FractalRect::boundingRect()const
{
    return QRect(0,0,width(),height());
}

QSize FractalRect::size()const
{
    return _size;
}
unsigned int FractalRect::width()const
{
    return _size.width();
}
unsigned int FractalRect::height()const
{
    return _size.height();
}




//
#endif // FRACTALRECT_H

